package com.ts.code.creator.util;

public class StringUtil {

    public static String firstUpper(String str) {
        return str.toUpperCase().substring(0, 1) + str.substring(1);
    }

    public static String firstLower(String str) {
        return str.toLowerCase().substring(0, 1) + str.substring(1);
    }

    public static String nameToUrl(String methodName) {
        char[] chars = methodName.toCharArray();
        String str = "/";
        for (char ch : chars) {
            if (ch > 'A' && ch <= 'Z') {
                str += "/" + (char)(ch + 32);
            } else {
                str += ch;
            }
        }
        return str;
    }

    public static String getEntityNameFromControllerName(String controllerName) {
        return controllerName.substring(0, controllerName.length() - "Controller".length());
    }

    public static boolean isNotBlank(String str) {
        return str != null && !str.trim().equals("");
    }

    public static boolean isBlank(String str) {
        return !isNotBlank(str);
    }

    public static void main(String[] args) {
        System.out.println(firstUpper("aaaName"));
        System.out.println(nameToUrl("aaaName"));
        System.out.println(getEntityNameFromControllerName("WelfareController"));
    }

}
